/**
 * Copyright (c) 2005-2012 https://github.com/zhangkaitao
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package com.monkey.core.domain;


import com.monkey.utils.MonkeyUtils;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * <p> 抽象实体基类，提供统一的ID，和相关的基本功能方法
 */
@MappedSuperclass
public abstract class BaseEntity<ID extends Serializable> extends AbstractEntity<ID> /*implements LogicDeleteable */{

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    protected ID id;

    @Column(name = "create_time")
    @Temporal(TemporalType.TIMESTAMP)
    protected Date createTime = MonkeyUtils.now();

    @Version
    @Column(name = "version")
    protected long version;

    /**
     * 逻辑删除flag
     */
    protected Boolean deleted = Boolean.FALSE;


    @Override
    public ID getId() {
        return id;
    }

    @Override
    public void setId(ID id) {
        this.id = id;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public long getVersion() {
        return version;
    }

    public void setVersion(long version) {
        this.version = version;
    }
//
//    @Override
//    public Boolean getDeleted() {
//        return this.deleted;
//    }
//
//    @Override
//    public void setDeleted(Boolean deleted) {
//        this.deleted = deleted;
//    }
//
//    @Override
//    public void markDeleted() {
//        this.deleted = Boolean.TRUE;
//    }
}
